home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Science / Survival Folder / Macros / Compute.Macro < prev    next >
Encoding:
Text File  |  1994-07-10  |  1.1 KB  |  35 lines  |  [TEXT/MJUA]

  1. MACRO 'Compute';
  2.  
  3. var
  4. status,time,grade,i,id,row,col,vars:integer;
  5. meanTime:real;
  6.  
  7. begin
  8.  
  9.     GETDATA('HD80:Mrp Project:Data:Ejemplo.surv');
  10.     GET(row,col,vars);{get number of rows columns and selected vars}
  11.     status:= 1;{column location of status var in the data matrix}
  12.  time:= 2; {column location of time var in the data matrix}
  13.  
  14. {first data is transformed with standard Pascal commands. Long execution time}
  15. {notice that data is accessed with the custom gDATA[] array definition.     }
  16.  
  17. meanTime:= 0.0;
  18. for i:= 0 to row - 1 do
  19.      begin
  20.         id:= i * col; {access to the start of the ith row of data matrix}
  21.      meanTime:= meanTime + gDATA[id + time]; {compute average time}
  22.         if gDATA[id + status] = 0 then gDATA[id + status] := -1;
  23.   end;
  24. meanTime:= meanTime/row;
  25. WRITE('The average time of the series is :',meanTime);
  26.  
  27. {now data is transformed with a custom COMPUTE command.Short execution time }
  28. {notice that data is accessed with the custom rDATA[] array definition.     }
  29.     COMPUTE
  30.         if rData[2] > 0 then rDATA[2] := rData[4] * rData[5];
  31.      rData[3]:= abs(rData[1]);
  32.     {you may add any other transform statement below}
  33.     end;{end of COMPUTE command}
  34. end;{end of MACRO}
  35.